package com.itjin.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itjin.model.domain.entity.ExamHelper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 考试助手Mapper接口
 */
@Mapper
public interface ExamHelperMapper extends BaseMapper<ExamHelper> {

  /**
   * 根据用户ID和课程ID查询考试助手信息
   */
  @Select("SELECT * FROM exam_helper WHERE user_id = #{userId} AND course_id = #{courseId} AND is_delete = 0")
  ExamHelper getByUserAndCourse(@Param("userId") Integer userId, @Param("courseId") Integer courseId);

  /**
   * 获取用户的所有考试助手信息
   */
  @Select("SELECT * FROM exam_helper WHERE user_id = #{userId} AND is_delete = 0 ORDER BY exam_date ASC")
  List<ExamHelper> getUserExamHelpers(@Param("userId") Integer userId);
}